package com.wz.compilerManual.tree;

import com.wz.compilerManual.Symbol;
import com.wz.compilerManual.add.symbol.S_epsilon;

import java.util.Iterator;

public class Node {
    private Symbol symbol;
    private Node rightBrother;
    private Node parent;
    private String data;
    private Node[] children;

    public Node(Symbol symbol) {
        this.symbol = symbol;
    }

    public Node(Symbol symbol, Node parent) {
        this.symbol = symbol;
        this.parent = parent;
    }

    public Node(Node parent, String data) {
        this.parent = parent;
        this.data = data;
    }

    public boolean isEndPoint(){
        return this.symbol instanceof S_epsilon;
    }

    public void setParent(Node parent) {
        this.parent = parent;
    }

    public void setData(String data) {
        this.data = data;
    }

    public Symbol getSymbol() {
        return symbol;
    }

    public String getData() {
        return data;
    }

    public Node getParent() {
        return parent;
    }

    public Node getRightBrother() {
        return rightBrother;
    }

    public void setRightBrother(Node rightBrother) {
        this.rightBrother = rightBrother;
    }

    public void setChildrenSize(int size) {
        this.children = new Node[size];
    }

    public void addChildren(Node child, int index) {
        children[index] = child;
    }
}